package com.weiwei.diancan.adapter;

import android.widget.TextView;

import com.weiwei.diancan.R;
import com.weiwei.diancan.bean.FindOrderBean;
import com.weiwei.diancan.bean.LoginBean;
import com.weiwei.diancan.cache.CacheConfig;

import java.util.List;

import weiwei.com.weiweilibrary.adapter.BaseQuickAdapter;
import weiwei.com.weiweilibrary.holder.BaseViewHolder;

/**
 * Created by BMW on 2016/11/25.
 */
public class SearchOrderAdapter extends BaseQuickAdapter<FindOrderBean.OrderListBean> {

    private final LoginBean login;

    public SearchOrderAdapter(List<FindOrderBean.OrderListBean> data) {
        super(R.layout.item_search_order, data);
        login = CacheConfig.getInst().getLogin();
    }

    @Override
    protected void convert(BaseViewHolder helper, FindOrderBean.OrderListBean item, int position) {
        TextView tv_name = helper.getView(R.id.tv_name);
        TextView tv_private = helper.getView(R.id.tv_private);
        TextView tv_table = helper.getView(R.id.tv_table);
        TextView tv_price = helper.getView(R.id.tv_price);
        tv_name.setText(item.getOrder_no());
        tv_private.setText(item.getDay());
        tv_price.setText("¥"+item.getOrder_price());
        List<LoginBean.TypeListBean> type_list = login.getType_list();
        for(LoginBean.TypeListBean typeListBean:type_list){
            List<LoginBean.TypeListBean.TabListBean> tab_list = typeListBean.getTab_list();
            for(LoginBean.TypeListBean.TabListBean tabListBean:tab_list){
                if(item.getTable_id().equals(tabListBean.getTab_id())){
                    tv_table.setText(tabListBean.getTab_name()+"("+item.getOrder_person()+"/"+tabListBean.getTab_person()+")");
                }
            }
        }
    }
}
